package com.xipu.yygh.cmn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xipu.yygh.model.cmn.Dict;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * description: 数据字典Mapper
 * @author: gql
 * @date: 2022/04
 */
@Mapper
public interface DictMapper extends BaseMapper<Dict> {

    /**
     * 查询数据字典Name
     * @param dictCode 数据字典编码
     * @param value v
     * @return dict记录
     */
    @Select("select * from yygh_cmn.dict where parent_id = (select id from dict where dict_code = #{dictCode}) and `value` = #{value}")
    Dict getNameByDictCodeAndValue(String dictCode, String value);

    /**
     * 查询所有的省份
     * @param dictCode 数据字典编码
     * @return dictList
     */
    @Select("select * from yygh_cmn.dict where parent_id = (select id from dict where dict_code = #{dictCode})")
    List<Dict> findByDictCode(String dictCode);
}
